import { fruitbowl } from './fruitbowl_withgroup.js'

const svg = d3.select('svg');

const makeFruit = type => ({
  type,
  id: Math.random()  
});

let fruits = d3.range(5)
  .map(() => makeFruit('apple'));
  
const render = () => {
  fruitbowl(svg, {
    fruits,
    height: +svg.attr('height')
  });
}


render();

setTimeout(()=> {
  fruits.pop();
  render();
}, 1000);

setTimeout(()=> {
  fruits[2].type = 'lemon';
  render();
}, 2000);

setTimeout(()=> {
  fruits = fruits.filter((d, i) => i != 1);
  render();
}, 3000);